package com.example.controlleradvice.pet;

import com.example.controller.pet.PersonalPetController;
import com.example.exception.pet.PetNotOwnedException;
import com.example.response.ApiResult;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author LeXin Huang
 * @date 2021年05月05日 10:11
 */
@Order(0)
@RestControllerAdvice(assignableTypes = PersonalPetController.class)
public class PetControllerAdvice {

    @ExceptionHandler(value = PetNotOwnedException.class)
    public ApiResult<ApiResult.ApiData> handle(PetNotOwnedException e) {
        return ApiResult.buildErrorResponse(e.getCode(), e.getMsg());
    }
}
